/*
	op: 
		00/01 	= Left Shift
		10		= Right Shift,0 Filled
		11		= Right Shift,with symbol extent
*/


module barrelShifter
(
    input 	wire    [31:0]			dataIn,
    input 	wire    [01:0]			op,		//
    input 	wire    [04:0]			shamt,
    output 	wire    [31:0]			dataOut
);
	wire            [31:0]          shift0;
	wire            [31:0]          shift1;
	wire            [31:0]          shift2;
	wire            [31:0]          shift3;
	wire            [31:0]          shift4;

	assign shift0 = (
                        (shamt[0])?
                        (op[1]?{{1{dataIn[31]&op[0]}},dataIn[31:1]}:{dataIn[30:0],1'b0}):
                        (dataIn)
                    );
    assign shift1 = (
                        (shamt[1])?
                        (op[1]?{{2{dataIn[31]&op[0]}},shift0[31:2]}:{shift0[29:0],2'b0}):
                        (shift0)
                    );
    assign shift2 = (
                        (shamt[2])?
                        (op[1]?{{4{dataIn[31]&op[0]}},shift1[31:4]}:{shift1[27:0],4'b0}):
                        (shift1)
                    );
    assign shift3 = (
                        (shamt[3])?
                        (op[1]?{{8{dataIn[31]&op[0]}},shift2[31:8]}:{shift2[23:0],8'b0}):
                        (shift2)
                    );
    assign shift4 = (
                        (shamt[4])?
                        (op[1]?{{16{dataIn[31]&op[0]}},shift3[31:16]}:{shift3[15:0],16'b0}):
                        (shift3)
                    );
    assign dataOut = shift4;

endmodule